package org.vvps.word;

import java.io.IOException;

import org.apache.hadoop.examples.WordCount.MapClass;
import org.apache.hadoop.examples.WordCount.Reduce;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;

public class WordCount {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		JobConf conf = new JobConf(WordCount.class);
		conf.setJobName("wordcount");

		// the keys are words (strings)
		conf.setOutputKeyClass(Text.class);
		// the values are counts (ints)
		conf.setOutputValueClass(IntWritable.class);

		conf.setMapperClass(WordMap.class);
		conf.setCombinerClass(WordReduce.class);
		conf.setReducerClass(WordReduce.class);
		 FileInputFormat.setInputPaths(conf, new Path(args[0])); 
		 FileOutputFormat.setOutputPath(conf, new Path(args[1])); 
		 JobClient.runJob(conf); 

	}

}
